package net.kelissa.divizor.util;


public class DataResizer2D
{
  private double[] mean = {-0.1, -0.1};
  private double resize = 1.5d;


  public int[] resize(double x, double y, int x_size, int y_size)
  {
    double newX = x - this.getMean()[0];
    double newY = y - this.getMean()[1];
    newX = newX / this.getResize();
    newY = newY / this.getResize();
    newX = (newX + 1) * x_size / 2;
    newY = (newY + 1) * y_size / 2;
    int[] res = {(int)newX, (int)newY};
    return res;
  }

  public double[] inverseResize(int x, int y, int x_size, int y_size)
  {
    double newX = (x * 2d / x_size) - 1 ;
    double newY = (y * 2d / y_size) - 1 ;
    newX = newX * this.getResize();
    newY = newY * this.getResize();
    newX = newX + this.getMean()[0];
    newY = newY + this.getMean()[1];
    double[] res = { newX, newY};
    return res;
  }


  public double[] getMean()
  {
    return mean;
  }
  public void setMean(double[] mean)
  {
    this.mean = mean;
  }
  public double getResize()
  {
    return resize;
  }
  public void setResize(double resize)
  {
    this.resize = resize;
  }
}
